package org.example;

import java.math.BigDecimal;
import java.time.LocalDateTime;

interface Adoptable{
    boolean isAvailable();
    void setAvailable(boolean available);
}

public abstract class Pet implements Adoptable {
    protected Integer id;
    protected String name;
    protected String breed;
    protected int age;
    protected int price;
    protected boolean available;
    protected String description;
    protected LocalDateTime createTime;

    public Pet(Integer id, String name, String breed, int age,
               int price, boolean available, String description) {
        this.id = id;
        this.name = name;
        this.breed = breed;
        this.age = age;
        this.price = price;

        this.available = available;
        this.description = description;
        this.createTime = LocalDateTime.now();
    }

    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public String getBreed() {
        return breed;
    }
    public void setBreed(String breed) {
        this.breed = breed;
    }

    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }

    public int getPrice() {
        return price;
    }
    public void setPrice(int price) {
        this.price = price;
    }

    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    @Override
    public boolean isAvailable() {
        return available;
    }

    @Override
    public void setAvailable(boolean available) {
        this.available = available;
    }


    public abstract String getSpecies();
    public abstract String makeSound();

    @Override
    public String toString() {
        String priceStr = (price == 0) ? "免费" : price + " 元";
        String status = available ? "可领养" : "已领养";

        return "【" + getSpecies() + "】\n" +
                "编号        ：" + id + "\n" +
                "名字        ：" + name + "\n" +
                "品种        ：" + breed + "\n" +
                "年龄        ：" + age + " 岁\n" +
                "价格        ：" + priceStr + "\n" +
                "状态        ：" + status + "\n" +
                "描述        ：" + description + "\n" +
                "叫声        ：" + makeSound() + "\n" +
                "创建时间    ：" + createTime;
    }
}

